package com.hyh.admin.sys.controller.base;

import com.hyh.ad.common.core.controller.BaseController;
import com.hyh.ad.common.core.domain.AjaxResult;
import com.hyh.ad.common.core.domain.entity.SysLogininfor;
import com.hyh.ad.common.core.page.TableDataInfo;
import com.hyh.admin.sys.service.ISysLoginInforService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/sysLoginInFor")
@Api(tags = "系统登录日志管理")
public class SysLoginInForController extends BaseController {

    @Autowired
    private ISysLoginInforService sysLoginInForService;

    /**
     * 查询登录日志列表
     * @return 日志列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询登录日志列表")
    public TableDataInfo listAllSelect(SysLogininfor sysLoginInfor) {
        startPage();
        List<SysLogininfor> sysLogininfors = sysLoginInForService.listAllSelect(sysLoginInfor);
        return getDataTable(sysLogininfors);
    }

    /**
     * 删除登录日志
     * @param sysLoginInfor 登录日志
     * @return 结果
     */
    @DeleteMapping("/delete")
    @ApiOperation(value = "删除登录日志")
    public AjaxResult delete(SysLogininfor sysLoginInfor) {
        return toAjax(sysLoginInForService.delete(sysLoginInfor));
    }

    /**
     * 删除登录日志
     * @param ids
     * @return 结果
     */
    @DeleteMapping("/deleteByIds/{ids}")
    @ApiOperation(value = "删除登录日志 批量删除")
    public AjaxResult deleteByIds(@PathVariable Long[] ids) {
        return toAjax(sysLoginInForService.deleteByIds(ids));
    }

    /**
     * 查看日志详情
     * @param   sysLoginInfor
     * @return
     */
    @GetMapping("/detail")
    @ApiOperation(value = "查看日志详情")
    public AjaxResult detail(SysLogininfor sysLoginInfor) {
        return AjaxResult.success(sysLoginInForService.detail(sysLoginInfor));
    }

    /**
     * 搜索日志
     * @param   sysLoginInfor
     * @return
     */
    @GetMapping("/search")
    @ApiOperation(value = "搜索日志")
    public TableDataInfo search(SysLogininfor sysLoginInfor) {
        startPage();
        List<SysLogininfor> sysLogininfors = sysLoginInForService.listAllSelect(sysLoginInfor);
        return getDataTable(sysLogininfors);
    }
}
